#ifndef CTEXTBROWSER_H
#define CTEXTBROWSER_H

#include <QList>
#include <QMap>

#include <QSplitter>
#include <QString>
#include <QTextBrowser>
#include <QUrl>
#include <QVariant>

#include <QtDebug>

class CTextBrowser : public QTextBrowser
{
    Q_OBJECT

    QList<QVariant> m_images;

    void debug(QString msg) { qDebug() << "[TextBrowser]\t" + msg; }
public:
    CTextBrowser(QWidget *parent=0);
    CTextBrowser(QSplitter *splitter): QTextBrowser(splitter) { }

    QVariant loadResource(int type, const QUrl& name);

    int addImage(QPixmap);
    void clearImages() { m_images.clear(); }
    int count() { return m_images.count(); }

public slots:
    void setSource(const QUrl &url);

private slots:
    void highlight(const QUrl&);

signals:
    void saveImage(const QPixmap&);
    void saveFile(int);
    void editField(int);
    void deleteField(int);
    void error(QString);
    void status(QString);
};

#endif // CTEXTBROWSER_H
